function hide() {	
	var t = document.getElementById("mytable");
	if (t.style.visibility == "hidden") {
		t.style.visibility = "visible";
	} else {
		t.style.visibility = "hidden";
	}	
}

function load(timeframe){
	var xmlhttp;
	if (window.XMLHttpRequest){//IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}else{//IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
	  if (xmlhttp.readyState==4 && xmlhttp.status==200){
	    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
	  }
	}
	xmlhttp.open("GET", "myServlet?timeframe=" + timeframe, true);
	xmlhttp.send();
}

function jQuery_load(timeframe){
	$.getJSON("myServlet?timeframe=" + timeframe, 
			function(json_obj) {
				var table_obj = $('<table></table>');
			    $.each(json_obj.list, function(i, data){
			    	table_obj.append($('<tr bgcolor="#fafafa"><td>'+(i+1)+'</td>'+
			    	'<td>'+data.articleId+'</td><td>'+
			        '<td><a href="articlePresentationAction.do?articleId='+data.articleId+'">'+data.title+'</a></td>'+
			        '<td>'+data.averageRating+'</td><td>'+data.numberOfRatings+'</td>'+
			        '<td>'+data.hitCount+'</td></tr>'));
			    });
			$('#mytable').empty();			
			$('#mytable').append(table_obj);
			//$('#mytable').replaceWith(table_obj);
		});
}

function confirmDelete(url) {		
	if (confirm("Do you really want to delete this article?")) { 
		if (confirm("The article and all its versions will be deleted.\nDo you want to proceed anyway?")) {
			document.location = url;
		}						
	} 
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}